using ArticleClientLib;
using HttpServerLib;
using 软文管理;

namespace 软件文管理
{
    internal static class Program
    {
        /// <summary>
        ///  The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            // To customize application configuration such as set high DPI settings or default font,
            // see https://aka.ms/applicationconfiguration.
            ApplicationConfiguration.Initialize();


            StartServer();


            UIDispach.ToLogin();

            //ArticleApi.SetAdminAccount("admin", "nickey2008");
            //UIDispach.ToArticleSync();
            //UIDispach.ToNewArticle();

            while (!UIDispach.AppExit)
            {
                UIDispach.Run();
            }
        }

        /// <summary>
        /// 启动软文预览服务端
        /// </summary>
        /// <exception cref="NotImplementedException"></exception>
        private static void StartServer()
        {
            //目录配置
            ServerConfig.ServerConfigDir = "config";

            var cfg = ServerConfig.Instance;
            var filePrv = new WindowsFilePrivider(cfg);

            RestServer server = new RestServer(cfg, filePrv, typeof(ArticleServer));
            server.Start();
        }
    }

}